<template>
  <div class="app-container">
    <h1 style="text-align: center">所有餐馆性价比</h1>
    <!--                        //类别,行政区,点评数,口味,环境,服务,人均消费,城市,Lng,Lat
    -->
    <h3 style="color: red;text-align: center">性价比最高的餐厅是1号，为 {{ this.data[0]._2 }}</h3>
    <el-table
        border
        :data="data"
        highlight-current-row
        v-loading="loading"
        style="width: 100%">
      <el-table-column label="序号" type="index" width="55" align="center"></el-table-column>

      <el-table-column
          prop="_2"
          align="center"
          label="性价比">
      </el-table-column>

      <el-table-column
          prop="_1.type"
          align="center"
          width="60"
          label="类别">
      </el-table-column>
      <el-table-column
          prop="_1.position"
          align="center"
          label="行政区">
      </el-table-column>
      <el-table-column
          prop="_1.comments"
          align="center"
          label="点评数">
      </el-table-column>
      <el-table-column
          prop="_1.flavor"
          align="center"
          label="口味">
      </el-table-column>
      <el-table-column
          prop="_1.environmental"
          align="center"
          label="环境">
      </el-table-column>
      <el-table-column
          prop="_1.service"
          align="center"
          label="服务">
      </el-table-column>
      <el-table-column
          prop="_1.consumption"
          align="center"
          label="人均消费">
      </el-table-column>
      <el-table-column
          prop="_1.city"
          align="center"
          label="城市">
      </el-table-column>
      <el-table-column
          prop="_1.lng"
          align="center"
          :formatter="dataFormat"
          label="经度">
      </el-table-column>
      <el-table-column
          prop="_1.lat"
          align="center"
          :formatter="dataFormat"
          label="纬度">
      </el-table-column>

      <el-table-column
          prop="_1.date"
          align="center"
          label="时间">
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
import request from "@/utils/request";

export default {
  name: "index",
  data() {
    return {
      loading: true,
      data: []
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      request({
        url: '/data/costPerformance',
        method: 'GET',
      }).then(v => {
        this.loading = false
        this.data = v.data
      })
    },
    dataFormat(row, column, cellValue, index) {
      return cellValue.toFixed(2)
    }
  }
}
</script>

<style scoped>

</style>
